#ifndef MAP_H
#define MAP_H

#include "..\common\types.h"
#include "..\common\common.h"
#include "..\common\string.h"

#include "camera.h"
#include "object.h"
#include "..\common\list.hpp"
#include "..\common\format.h"

#include <string.h>
#include <stdio.h>
struct Vertex;
//#include "..\..\WorldCompiler\dataStructures.h"
class	CMap
{
	
private:
	string			m_Identity;
	Vertex			*m_pVertices;
	//Group			*m_pGroups;
	unsigned int			m_groupCount;

	MapHeader		m_infoHeader;
	MapGlobalInfo	m_infoGlobal;
	MapFogInfo		m_fogInfo;
	MapEnvInfo		m_envInfo;
	IModel			*pMesh;

	//inline void		checkBounds(Vertex **faceVerticesPtr, VECTOR3F* minmixPtr);
	bool			readFace(FILE *filePtr, Vertex **faceVerticesPtr);
	//bool			readGroup(FILE *filePtr, Group *groupPtr);
	void			readTexture(FILE *filePtr, string *sz_texture, string *sz_normal);
	/*bool			buildVertexArray(Vertex	**vertexArrayPtr, unsigned int **indiceArrayPtr,
						unsigned int totalVertexCount, Group *groupPtr, unsigned int groupCount);*/
	bool			readObjects(FILE *filePtr);

	virtual bool objectInterpreter(worldEntity &objectInfo, CObject **objectPtr) = 0;
	virtual bool objectInterpreter(worldLightEntity &lightInfo, CObject **objectPtr) = 0;
	HRESULT	loadMapData(string &sz_filename);

	

	
	HRESULT Load(string &sz_filename);
	HRESULT Release(void);




public:
	CMap(void);
	virtual ~CMap(void);

	virtual void onObjectCollision(CObject *objectPtr) {};

	
	//void	setEntityReadFunc(HRESULT (*readFunc) (worldEntity &, CObject **));

	void	Draw(CCamera *pCamera);
	void	Update(float dt);
	friend class CEngine;	
};
#endif
